package pam.sample;

import pam.lang.XMLObject;

public class Book implements XMLObject {

	private String id;
	private String author;
	private String title;
	private String description;
	private double price;

	public Book() {
		super();
	}

	public Book(String id, String author, String title, String description,
			double price) {
		super();
		this.id = id;
		this.author = author;
		this.title = title;
		this.description = description;
		this.price = price;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String toXML() {
		StringBuffer sb = new StringBuffer();
		sb.append("<Book>");

		sb.append("<ID>");
		sb.append(getId() == null ? "" : getId());
		sb.append("</ID>");

		sb.append("<Author>");
		sb.append(getAuthor() == null ? "" : getAuthor());
		sb.append("</Author>");

		sb.append("<Title>");
		sb.append(getTitle() == null ? "" : getTitle());
		sb.append("</Title>");

		sb.append("<Price>");
		sb.append(getPrice());
		sb.append("</Price>");

		sb.append("<Description>");
		sb.append("<![CDATA[");
		sb.append(getDescription() == null ? "" : getDescription());
		sb.append("]]>");
		sb.append("</Description>");
		sb.append("</Book>");

		return sb.toString();
	}

}
